const data = {
  text: "hello world",
};

const bucket = new Set();
const obj = new Proxy(data, {
  get(target, key) {
    bucket.add(effect);
    return target[key];
  },
  set(target, key, val) {
    target[key] = val;
    bucket.forEach((fn) => fn());
    return true;
  },
});

function effect() {
  document.body.innerHTML = obj.text;
}
effect();
setTimeout(() => {
  obj.text = "hello zhenzhenzhen";
}, 2000);
